package com.xinchao.job.service;

import com.xinchao.common.dto.CityCmccInfoDTO;
import com.xinchao.job.mapper.dmp.CityCmccInfoMapper;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 城市中国移动信息实现类
 * @author dxy
 * @date 2018/9/4 16:13
 */
@Service(value = "cityCmccInfoService")
public class CityCmccInfoService {
	@Autowired
	private CityCmccInfoMapper cityCmccInfoMapper;

	public Map<String, CityCmccInfoDTO> getCityCmccInfoMap() {
		//城市中国移动信息（键为城市，值为CityCmccInfoVO）
		Map<String, CityCmccInfoDTO> cityCmccInfoMap = new HashMap<>();
		List<CityCmccInfoDTO> cityCmccInfoList = cityCmccInfoMapper.listAllCityCmccInfo();
		if (CollectionUtils.isNotEmpty(cityCmccInfoList)) {
			for (CityCmccInfoDTO vo : cityCmccInfoList) {
				String city = vo.getCity();
				if (StringUtils.isNotBlank(city)) {
					cityCmccInfoMap.put(city, vo);
				}
			}
		}
		return cityCmccInfoMap;
	}
}